<?php
/**
* @package controller
* @file indexController.php
* @date 25.01.2010
* @version 1.0
* @copyright Corjanta
* @author Harinath Reddy .
* @todo phpDoc comments
*/
require_once 'Zend/Controller/Action.php';

class News_IndexController extends Cms_Controller_Action
{
	public function init()
	{
	$this->view->siteTitle = 'Corjanta - Static';
	$this->view->params ='';
	$this->view->videos = '/'.$this->CONFIG->path->videos;
	$this->view->vsmall = '/'.$this->CONFIG->path->vsmallThumb;
	$this->view->vbig = '/'.$this->CONFIG->path->vbigThumb;
	}	
	public function indexAction()    
	{  
		$result = Doctrine::getTable('News')->getNews();
		//echo '<pre>';print_r($result);exit;
		$this->view->result = $result;		
	}
	public function indexsssAction()    
	{  
		$result = Doctrine::getTable('News')->getNews('',1,10);
		//echo '<pre>';print_r($result);exit;
		$this->view->idea = $result['result'];
		$this->view->pager = $result['paging'];
	}
	public function listPaginateAction()
	{
		$currentPage = $this->_getParam('current_page') == 0? 1:$this->_getParam('current_page');
		$resultsPerPage = $this->_getParam('results_per_page') == 0? 15:$this->_getParam('results_per_page');
		$result = Doctrine::getTable('News')->getNews('',$currentPage,$resultsPerPage);
		$this->view->idea = $ideaDetails['result'];
		$this->view->pager = $ideaDetails['paging'];
		$this->view->cpage = $currentPage;
		$this->view->rpp = $resultsPerPage;
		$this->view->parameter = $parameter;
		$resultSet = $ideaDetails['paging'];
		$jsonData['output'] = $this->view->render('index/list.html');
		$jsonData['pages'] = $resultSet['pages'];
	    $jsonData['pager'] = $resultSet['pager'];
	    $jsonData['currentPage'] = $resultSet['currentPage'];
		$jsonData['resultsCount'] = $resultSet['resultsCount'];
		$jsonData['cpage'] = $currentPage;
		$jsonData['rpp'] = $resultsPerPage;
		$pstv = (($resultsPerPage*($resultSet['currentPage']-1))+1);
		//$jsonData['resultsCount'] = $currentPage.'******'.$this->_getParam('current_page').'*****'.$resultsPerPage;
		$this->_helper->json->sendJson($jsonData);
		

	}

	public function viewAction()
	{
		
		$contentId = base64_decode($this->_getParam('id'));		
	    $content = Doctrine::getTable('News')->getNewsDetails($contentId);
		//echo '<pre>';print_r($content);exit;
		if(count($content)!=0){
		   $this->view->cintentTitle = stripslashes($content[0]['news_title']);
		   $this->view->cintentDesc = stripslashes($content[0]['news_desc']);
		} else{
		   $this->view->cintentTitle="";
		   $this->view->cintentDesc="";
		}
	
	}

	public function aboutAction()
	{
		$content = Doctrine::getTable('SiteContent')->getDetails(1);
		if(count($content)!=0){
		   $this->view->cintentTitle = $content[0]['content_title'];
		   $this->view->cintentDesc = $content[0]['content_desc'];
		} else{
		   $this->view->cintentTitle="";
		   $this->view->cintentDesc="";
		}
	}
	
	public function whyCorjantaAction()
	{
		$content = Doctrine::getTable('SiteContent')->getDetails(3);
		if(count($content)!=0){
		   $this->view->cintentTitle = $content[0]['content_title'];
		   $this->view->cintentDesc = $content[0]['content_desc'];
		} else{
		   $this->view->cintentTitle="";
		   $this->view->cintentDesc="";
		}
	}

	public function contactUsAction()
	{
		$content = Doctrine::getTable('SiteContent')->getDetails(2);
		if(count($content)!=0){
		   $this->view->cintentTitle = $content[0]['content_title'];
		   $this->view->cintentDesc = $content[0]['content_desc'];
		} else{
		   $this->view->cintentTitle="";
		   $this->view->cintentDesc="";
		}
	}

	public function howWorksAction()
	{
		$content = Doctrine::getTable('SiteContent')->getDetails(5);
		if(count($content)!=0){
		   $this->view->cintentTitle = $content[0]['content_title'];
		   $this->view->cintentDesc = $content[0]['content_desc'];
		} else{
		   $this->view->cintentTitle="";
		   $this->view->cintentDesc="";
		}
	}

	public function benfitsAction()
	{
		$content = Doctrine::getTable('SiteContent')->getDetails(6);
		if(count($content)!=0){
		   $this->view->cintentTitle = $content[0]['content_title'];
		   $this->view->cintentDesc = $content[0]['content_desc'];
		} else{
		   $this->view->cintentTitle="";
		   $this->view->cintentDesc="";
		}
	}

	public function needDemoAction()
	{
		$content = Doctrine::getTable('SiteContent')->getDetails(7);
		if(count($content)!=0){
		   $this->view->cintentTitle = $content[0]['content_title'];
		   $this->view->cintentDesc = $content[0]['content_desc'];
		} else{
		   $this->view->cintentTitle="";
		   $this->view->cintentDesc="";
		}
	}
	
	
	
	
}